{extend name="adminheader:header"/}
{block name="content"}
	<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                	<div class="ibox-title">
                        <h5>修改订单信息</h5>
                    </div>
                    <div class="ibox-content">
                        <form action="{:url('/admin/Orders/editPost')}" method="post" class="form-horizontal js-ajax-form m-t">
                            <input type="hidden" name="id" value="{$list.id}" />
                            <div class="form-group">
                                <label class="col-sm-3 control-label">订单号<span class="form-required">*</span></label>
                                <div class="col-md-6 col-sm-10">
                                    <input name="o_code" type="text" class="form-control" value="{$list.o_code}" placeholder="请输入订单号" />
                                </div>
                                <i style="color:#FF0000">格式：时间+6位数 20180716000001</i>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">会员姓名<span class="form-required">*</span></label>
                                <div class="col-md-6 col-sm-10">
                                     <select class="form-control" name="uid" id="usernames">
                                        <option value="">- - - 请选择会员姓名 - - -</option>
                                        {if condition="$users neq null"}
                                            {volist name="users" id="vo"}
                                                <option value="{$vo.id}" {$list['uid']==$vo['id'] ? 'selected':''}>{$vo.u_name}</option>
                                            {/volist}
                                        {else/}
                                            <option value="" disabled="disabled">暂时无会员</option>
                                        {/if}
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">会员的收货地址<span class="form-required">*</span></label>
                                <div class="col-md-6 col-sm-10">
                                    <select class="form-control" name="aid" id="useraddress">
                                        <option value="">- - - 请选择会员的收货地址 - - -</option>
                                        {if condition="$address neq null"}
                                            {volist name="address" id="vo"}
                                                <option value="{$vo.id}" {$list['aid']==$vo['id'] ? 'selected':''}>{$vo.a_address}</option>
                                            {/volist}
                                        {else/}
                                            <option value="" disabled="disabled">该会员暂时无收货地址</option>
                                        {/if}
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">订单金额<span class="form-required">*</span></label>
                                <div class="col-md-6 col-sm-10">
                                    <input name="o_tprice" type="text" class="form-control" value="{$list.o_tprice}" placeholder="请输入订单金额" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">付款方式<span class="form-required">*</span></label>
                                <div class="col-md-6 col-sm-10">
                                   <input type="radio" name="o_type" id="inlineRadio1" value="1" {$list.o_type==1 ?'checked':''} style="cursor: pointer;margin-right:5px"/>余额&nbsp;&nbsp;&nbsp;&nbsp;
                                   <input type="radio" name="o_type" id="inlineRadio2" value="2" {$list.o_type==2 ?'checked':''} style="cursor: pointer;margin-right:5px"/>支付宝&nbsp;&nbsp;&nbsp;&nbsp;
                                   <input type="radio" name="o_type" id="inlineRadio3" value="3" {$list.o_type==3 ?'checked':''} style="cursor: pointer;margin-right:5px"/>微信
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">状态<span class="form-required">*</span></label>
                                <div class="col-md-6 col-sm-10">
                                   <input type="radio" name="o_status" id="inlineRadio1" value="1" {$list.o_status==1 ?'checked':''} style="cursor: pointer;margin-right:5px"/>未付款&nbsp;&nbsp;&nbsp;&nbsp;
                                   <input type="radio" name="o_status" id="inlineRadio2" value="2" {$list.o_status==2 ?'checked':''} style="cursor: pointer;margin-right:5px"/>已付款&nbsp;&nbsp;&nbsp;&nbsp;
                                   <input type="radio" name="o_status" id="inlineRadio3" value="3" {$list.o_status==3 ?'checked':''} style="cursor: pointer;margin-right:5px"/>已取消
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">付款时间/取消时间<span class="form-required">*</span></label>
                                <div class="col-md-6 col-sm-10">
                                    <input class="form-control js-bootstrap-datetime" type="text" name="o_time" value="{:date('Y-m-d H:i',$list['o_time'])}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">物流公司</label>
                                <div class="col-md-6 col-sm-10">
                                    <input class="form-control" type="text" name="o_company" value="{$list.o_company}" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">物流单号</label>
                                <div class="col-md-6 col-sm-10">
                                    <input class="form-control" type="text" name="o_snumber" value="{$list.o_snumber}" />
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-3">
                                    <button class="btn btn-primary js-ajax-submit" type="submit">保存</button>
                                    <a class="btn btn-default" href="{:url('/admin/orders/index')}">返回</a>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
<script src="/admin/js/admin.js"></script>
<script type="text/javascript">
    $(document).ready(function(){

        /* 选择时 */
        $('#usernames').change(function(){
            $("#useraddress").find("option").remove();
            var uid = $('#usernames').find("option:selected").val();
             $.ajax({
                type:"get",
                url:"{:url('/admin/Orders/getUsersAddress')}",
                data:{'uid':uid},
                dataType:'json',
                success:function(res){ 
                    var data = res.data;
                    if(data.length !== 0){
                        var str = '';
                        for(var i=0;i<data.length;i++){
                            str+= "<option value='"+data[i].id+"'>"+data[i].a_address+"</option>";
                        }

                        $("#useraddress").append('<option value="">- - - 请选择会员的收货地址 - - -</option>'+str);

                    }else{

                        $('#useraddress').append('<option value="">- - - 请选择会员的收货地址 - - -</option><option value="" disabled="disabled">该会员暂时无收货地址</option>');
                    }
                    
                },
                error:function(res){
                    layer.alert("服务器出错!")
                }
            });
        });
        
    });
</script>
{/block}